package user

import (
	"context"
	"github.com/cloudwego/kitex/client/callopt"
	"github.com/cloudwego/kitex/pkg/klog"
	user "userrpc/kitex_gen/user"
)

func RegisterUser(ctx context.Context, req *user.User, callOptions ...callopt.Option) (resp *user.Response, err error) {
	resp, err = defaultClient.RegisterUser(ctx, req, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "RegisterUser call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func Login(ctx context.Context, req *user.User, callOptions ...callopt.Option) (resp *user.User, err error) {
	resp, err = defaultClient.Login(ctx, req, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "Login call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func Logout(ctx context.Context, req *user.User, callOptions ...callopt.Option) (resp *user.Response, err error) {
	resp, err = defaultClient.Logout(ctx, req, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "Logout call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func EditPassword(ctx context.Context, req *user.User, callOptions ...callopt.Option) (resp *user.Response, err error) {
	resp, err = defaultClient.EditPassword(ctx, req, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "EditPassword call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}
